package com.frame.servlet;

import com.frame.bean.Img;
import com.frame.service.ImgService;
import com.frame.util.PropUtil;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * 视图转发
 */
@WebServlet(name = "ImgListServlet",urlPatterns = "/file_list")
public class ImgListServlet extends HttpServlet {
    private static final long servialVersionUID = 1L;
    private ImgService imgService = new ImgService();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        List<Img> imgList = imgService.findAllImg();
        req.setAttribute("ImgList",imgList);
        req.getRequestDispatcher(PropUtil.getProperty("frame.webapp.jsp_path")+"list.jsp").forward(req,resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
